package com.xhx.stream.stream;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;

import com.xhx.stream.dto.HumanDTO;
import com.xhx.stream.dto.VehicleDTO;

import lombok.extern.slf4j.Slf4j;

/**
 * 自定义消息消费者
 * 
 * @author xhx
 */
@Slf4j
@EnableBinding(CustomSinkChannel.class)
public class CustomReceiveService {

	@StreamListener(CustomSinkChannel.LOG_INPUT)
	public void receiveLog(String payload) {
		log.info("Log payload = {}", payload);
	}

	@StreamListener(CustomSinkChannel.FACE_INPUT)
	public void receiveFace(Object payload) {
		log.info("Face payload = {}", payload);
	}

	@StreamListener(CustomSinkChannel.HUMAN_INPUT)
	public void receiveHuman(HumanDTO payload) {
		log.info("Human payload = {}", payload);
	}

	@StreamListener(CustomSinkChannel.VEHICLE_INPUT)
	public void receiveVehicle(VehicleDTO payload) {
		log.info("Vehicle payload = {}", payload);
		// 测试异常重试
		throw new RuntimeException("异常测试 -- 重试机制");
	}

}
